/* 
 * Copyright [2018] [Alex/libo(liboware@gmail.com)]
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyt.tomcat;

import com.hyt.tomcat.api.TomcatLauncher;

import com.hyt.tomcat.config.TomcatBootType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.Setter;

/** 
 * @author LiBo/Alex
 * @version V1.0 
 */
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TomcatBootStrap {

    @Setter
    private TomcatLauncher tomcatLauncher;
 
    /**
     * <b>启动服务</b>
     * @param bootType
     * @exception
     */
    public void start(TomcatBootType bootType) {
        if(tomcatLauncher == null)
            throw new NullPointerException("未设置系统Laucher触发器组件！");
        boolean flag = tomcatLauncher.start(bootType);
        if(flag)
            System.out.println("启动tomcat成功!");
        else
            System.err.println("启动tomcat失败!");
    }

    /**
     * 停止服务
     */
    public void stop() {
        if(tomcatLauncher == null)
            throw new NullPointerException("未设置系统Laucher触发器组件！");
        tomcatLauncher.stop(null);
    }
    
}
